package practise.dynamicproxy;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

/**
 * @author: 默苍璃
 * @date: 2023-01-10 15:29
 */
public class VehicleInvocationHandler implements InvocationHandler {

    private final dynamicproxy.Vehicle vehicle;

    public VehicleInvocationHandler(dynamicproxy.Vehicle vehicle) {
        this.vehicle = vehicle;
    }


    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        System.out.println("---------before-------");
        Object invoke = method.invoke(vehicle, args);
        System.out.println("---------after-------");

        return invoke;
    }

}
